package com.efast.cafe.framework.jdbc.bean;

import java.util.HashMap;
import java.util.Map;

public class JdbcTypeResolveToLov {
	
	class LovType{
		public final static int STRING = 0x0001;
		public final static int INT = 0x0002;
		public final static int DOUBLE = 0x0003;
		public final static int DATE = 0x0004;
		public final static int BOOLEAN = 0x0005;
		public final static int FILE = 0x0006;
		public final static int JSON = 0x0007;
		public final static int ENTITY = 0x0008;
	}
	
	
	
	
	 class JdbcType{
		public final static String TINYINT = "tinyint";
		public final static String SMALLINT = "smallint";
		public final static String MEDIUMINT = "mediumint";
		public final static String INT = "int";
		public final static String INTEGER = "integer";
		public final static String BIGINT = "bigint";
		public final static String FLOAT = "float";
		public final static String DOUBLE = "double";
		public final static String DECIMAL = "decimal";
		public final static String CHAR = "char";
		public final static String VARCHAR = "varchar";
		public final static String TINYBLOB = "tinyblob";
		public final static String TINYTEXT = "tinytext";
		public final static String BLOB = "blob";
		public final static String TEXT = "text";
		public final static String MEDIUMBLOB = "mediumblob";
		public final static String MEDIUMTEXT = "mediumtext";
		public final static String LONGBLOB = "longblob";
		public final static String LONGTEXT = "longtext";
		public final static String ENUM = "enum";
		public final static String DATE = "date";
		public final static String TIME = "time";
		public final static String YEAR = "year";
		public final static String DATETIME = "datetime";
		public final static String TIMESTAMP = "timestamp";
		public final static String JSON = "json";
		
	}
	
	 static Map<String,Integer> jdbcTypeToLov;
	
	static{
		jdbcTypeToLov = new HashMap<String,Integer>();
		jdbcTypeToLov.put(JdbcType.TINYINT,LovType.INT);
		jdbcTypeToLov.put(JdbcType.SMALLINT,LovType.INT);
		jdbcTypeToLov.put(JdbcType.INTEGER,LovType.INT);
		jdbcTypeToLov.put(JdbcType.INT,LovType.INT);
		jdbcTypeToLov.put(JdbcType.MEDIUMINT,LovType.INT);
		jdbcTypeToLov.put(JdbcType.BIGINT,LovType.INT);
		
		jdbcTypeToLov.put(JdbcType.DOUBLE,LovType.DOUBLE);
		jdbcTypeToLov.put(JdbcType.FLOAT,LovType.DOUBLE);
		jdbcTypeToLov.put(JdbcType.DECIMAL,LovType.DOUBLE);
		
		jdbcTypeToLov.put(JdbcType.DATE,LovType.DATE);
		jdbcTypeToLov.put(JdbcType.TIME,LovType.DATE);
		jdbcTypeToLov.put(JdbcType.YEAR,LovType.DATE);
		jdbcTypeToLov.put(JdbcType.DATETIME,LovType.DATE);
		jdbcTypeToLov.put(JdbcType.TIMESTAMP,LovType.DATE);
		
		jdbcTypeToLov.put(JdbcType.VARCHAR,LovType.STRING);
		jdbcTypeToLov.put(JdbcType.CHAR,LovType.STRING);
		jdbcTypeToLov.put(JdbcType.TEXT,LovType.STRING);
		jdbcTypeToLov.put(JdbcType.TINYTEXT,LovType.STRING);
		jdbcTypeToLov.put(JdbcType.MEDIUMTEXT,LovType.STRING);
		jdbcTypeToLov.put(JdbcType.LONGTEXT,LovType.STRING);
		
		jdbcTypeToLov.put(JdbcType.JSON,LovType.ENTITY);
		
		
		
		
		
	}
	public static Integer resolverToLOV(String jdbcType){
		if(jdbcTypeToLov.containsKey(jdbcType)){
			return jdbcTypeToLov.get(jdbcType);
		}else{
			return null;
		}
		
		
	}

}
